package com.example.drugaiservice.controller;


import com.example.drugaiservice.common.result.Result;
import com.example.drugaiservice.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@CrossOrigin
@RequestMapping("/rank")

public class RankController {
    @Autowired
    private RedisService redisService;
    @PostMapping("/preheat")
    public Result preHeat(){
        redisService.preHeatZSet();
        return Result.success();
    }
    @GetMapping("/getRank")
    public Result getRank() {
        return Result.success(redisService.getTop10ByZSet());
    }
    @PostMapping("/clear")
    public Result clearRedis(){
        redisService.clearRedis();
        return Result.success();
    }
}
